package com.mayp.supermarket.sales.policy;

/**
 * @Description :促销策略
 * @Author : mayp
 * @Date: 2024/7/12  11:21
 */
public class PromotionStrategy implements PricingStrategy {
    // 起步价
    private final double threshold;
    // 折扣
    private final double discount;

    public PromotionStrategy(double threshold, double discount) {
        this.threshold = threshold;
        this.discount = discount;
    }

    @Override
    public double applyDiscount(double totalPrice) {
        return totalPrice >= threshold ? totalPrice - discount : totalPrice;
    }
}